C128_HiResolutionGraphic Part II How does it work using poke command? ------------------------------------- 5 gs=8192:nl=320 10 color 1,5:graphic 2,1,6 14 for a = 3 to 319 step 8 16 poke 8192+319+a,255:next 18 for a = 0 to 39 20 poke 7168+(2*40)+a,cc 22 cc=(rnd(1)*9)+2:next 26 for b = 0 to 39 28 pokegs+(nl*4)+0+(b*8),255 30 pokegs+(nl*4)+1+(b*8),129 32 pokegs+(nl*4)+2+(b*8),129 34 pokegs+(nl*4)+3+(b*8),24 36 pokegs+(nl*4)+4+(b*8),24 38 pokegs+(nl*4)+5+(b*8),129 40 pokegs+(nl*4)+6+(b*8),129 42 pokegs+(nl*4)+7+(b*8),255:next ------------------------------------- PIXELS This small listing is responsible for the picture number one. So graphic part is starting at the address $2000, dec 8192. As you can see, it's made of 8x8 bits or 8 byte. Therefore it was necessary to do a step 8 jumps to create a straight line from 0 to 319. we are starting at line number 12 (0-3 + 319 which is a jump to next 8x8 bits), that is 4+8 = 12 Location is starting from 0, not 1 as far as i can see. Many books are writing 320 x 200 resolution. However, if you do from 1 to 320, then you have a gap of one pixel at start. COLORS You can use a Color command, but if you place it after the Graphic command, it'll be active first the second start. Ergo, first Color information, then Graphic mode. In regard of positions, it is not the same as Graphic area and it also isn't the same area as Color Map for 40 Characters Text-Screen { $d800 - $dbe7, dec 55296 - 56295 } Color for Graphic screen is located at the address { $1c00 - $1fff or dec 7168 - 8191 } Exactly, that's where usually BASIC lines are. However, when you do Graphic, then this is moving Basic to a new location $4000, dec 16384. Previous Basic area is given free for the Graphic Color Registers and Graphic screen itself { 9KB, until $3FFF }. Unfortunatelly, it's only 1KB big, same as for Text-Screen. But Text-Screen is 1KB, Graphic is 8KB. Meaning, we are missing 7KB of area to cover all pixels individually and have therefore the big boy 8 byte color box. As shown already, you can work with that too with a little more calculations are imaginations. Precisely said, the above lines 28 to 42 can't have 64 individual colors as it would be great, but only one for this are. { can have more if you move the box on a border of 4 x 8 bytes and use each color for the box. So this box is then taking place on 4 different location, occupying 4 pixel each location, ergo 4 colors possible. Check the second picture } And because it's a 8 x 8 bits or 8 byte big color box you need only 40 of them to reach the end of 320 pixels { 8 x 40 = 320 } Color Sharing: Knowing how C128 Graphic is working, this shouldn't be possible... A bug? ------------------------------------- Listing 2 5 gs=8192:nl=320:cs=7168:cl=40 10 color 1,5:graphic 2,1,16 14 for a = 3 to 319 step 8 16 poke 8192+319+a,255:next 18 for a = 0 to 39 20 poke 7168+(2*40)+a,cc 22 cc=(rnd(1)*9)+2:next 26 for b = 0 to 39 28 pokegs+(nl*4)+0+(b*8),255 30 pokegs+(nl*4)+1+(b*8),129 32 pokegs+(nl*4)+2+(b*8),129 34 pokegs+(nl*4)+3+(b*8),24 36 pokegs+(nl*4)+4+(b*8),24 38 pokegs+(nl*4)+5+(b*8),129 40 pokegs+(nl*4)+6+(b*8),129 42 pokegs+(nl*4)+7+(b*8),255:next 50 rem :::: share your colors 53 for y=0 to 9 step 2 55 for x=0to19 60 fora=3to7:poke cs+(x*2)+(cl*(6+y)),l 61 l=(rnd(1)*14)+1 65 pokegs+(x*16)+(nl*(6+y))+a,255:next 70 fora=3to7:pokecs+1+(x*2)+(cl*(6+y)),o 71 o=(rnd(1)*14)+1 75 pokegs+8+(x*16)+(nl*(6+y))+a,240:next 80 fora=0to3:poke cs+(x*2)+(cl*(7+y)),k 81 k=(rnd(1)*14)+1 85 pokegs+(x*16)+(nl*(7+y))+a,15:next 90 fora=0to3:pokecs+1+(x*2)+(cl*(7+y)),i 91 i=(rnd(1)*14)+1 95 pokegs+8+(x*16)+(nl*(7+y))+a,255:next 96 next:next